<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
    <div id="root">
        <button @click="sub"> - </button>
        <span>{{number}}</span>
        <button @click="add"> + </button>
    </div>
    <script>
        Vue.config.productionTip = false
        new Vue({
            el:'#root',
            data:{
                number:0
            },
            methods: {
                add(){
                    if(this.number>=10){
                        alert('已经到最大了')
                    }else{
                        this.number++ 
                    }
                    
                },
                sub(){
                    if(this.number<=0){
                        alert('已经到0了')
                    }else{
                        this.number--
                    }
                    
                }
            },
        })
    </script>
</body>
</html>